package email;

import java.util.ArrayList;
import java.util.Collection;

public class Thread {
	/**
	 * Id of the Thread
	 */
	private long id;
	/**
	 * Name of the Thread
	 */
	private String name;
	/**
	 * Emails in this thread
	 */
	private ArrayList<ReceivedMessage> emails;
	
	private boolean isReplyThread;
	
	/**
	 * Basic Constructor without an id or name for the Thread
	 */
	public Thread(){
		id = 0;
		name = "";
		emails = new ArrayList<ReceivedMessage>();
		setReplyThread(false);
	}
	
	/**
	 * Constructor with id but no name for the Thread
	 * @param id
	 */
	public Thread(long id){
		this.id = id;
		name = "";
		emails = new ArrayList<ReceivedMessage>();
		setReplyThread(false);
	}
	
	/**
	 * Constructor with id and name for the Thread
	 * @param id
	 * @param name
	 */
	public Thread(long id, String name){
		this.id = id;
		this.name = name;
		emails = new ArrayList<ReceivedMessage>();
		setReplyThread(false);
	}
	
	public Thread(long id, String name, ArrayList<ReceivedMessage> emails){
		this.id = id;
		this.name = name;
		this.emails = emails;
		setReplyThread(false);
	}
	
	/**
	 * Sets the emails in this Thread to a list of the provided emails
	 * @param emails
	 */
	public void setEmails(ArrayList<ReceivedMessage> emails){
		this.emails.clear();
		this.emails.addAll(emails);
	}
	
	public ArrayList<ReceivedMessage> getEmails(){
		return emails;
	}
	
	public void addEmail(ReceivedMessage email){
		emails.add(email);
	}
	
	public void addEmail(ReceivedMessage email, int index){
		emails.add(index, email);
	}
	
	public void removeEmail(ReceivedMessage email){
		emails.remove(email);
	}
	
	
	
	public void setId(long l){
		this.id = l;
	}
	
	public long getId(){
		return id;
	}
	
	public void setName(String name){
		this.name = name;
	}
	
	public String getName(){
		return name;
	}

	public boolean isReplyThread() {
		return isReplyThread;
	}

	public void setReplyThread(boolean isReplyThread) {
		this.isReplyThread = isReplyThread;
	}
}
